<?php
load_info_var($cf_controller);	   //加载smarty变量
load_file('log_class', LIB_PATH);

$main = new Log($db);
$id = isset($_POST['id']) ? intval($_POST['id']) : intval($_GET['id']);
$self = isset($_POST['self']) ? intval($_POST['self']) : intval($_GET['self']);
$return_page = $cf_pre_page ? $cf_pre_page : $cf_self_page;

switch ($cf_action) {
    case "index":
	$smarty->mypage($cf_controller, $cf_action, 0);

	//echo get_low_price(0,0,5);
	//exit;


	$stype = isset($_POST['stype']) ? trim($_POST['stype']) : trim($_GET['stype']);
	$stype2 = isset($_POST['stype2']) ? trim($_POST['stype2']) : trim($_GET['stype2']);
	$skey = isset($_POST['skey']) ? trim($_POST['skey']) : urldecode($_GET['skey']);
	$skey2 = isset($_POST['skey2']) ? trim($_POST['skey2']) : urldecode($_GET['skey2']);
	$skey3 = isset($_POST['skey3']) ? trim($_POST['skey3']) : urldecode($_GET['skey3']);
    $date = isset($_POST['date']) ? trim($_POST['date']) : $_GET['date'];

	$where = '1';


	if ($skey) {
	    $where .= " and log_user = '" . $skey . "'";
	}
	if ($skey2) {
	    $where .= " and log_uid = '" . $skey2 . "'";
	}
	if ($stype) {
	    $where .= " and log_type = '" . $stype . "'";
	}
    if($date){
        $where .= " and date_format(log_create_time,'%Y-%m-%d')  ='".$date."'";
    }





    load_file('page_class', LIB_PATH);
	$MyPage = new Mypage($db);
	$field = '*';
	$data_ary = $MyPage->from_sql($field, "data_user_score_log", $where,"log_id DESC", intval($_GET['cpage']), "50");
	$page = $MyPage->get_page($data, $cf_self_page . '?dpt=' . $cf_dpt . '&skey=' . $skey . '&skey2=' . $skey2 . '&skey3=' . $skey3 . '&stype=' . $stype . '&stype2=' . $stype2. '&self=' . $self.'&date=' . $date);
	//echo $MyPage->get_sql();
	if($data_ary){
		foreach($data_ary as $k=>$v){
			if($v['log_score']<'0'){
				$minus_score += $v['log_score'];
			}else{
				$plus_score += $v['log_score'];
			}
			
			
		}
		
	}

	break;
	my_jump('非法操作!');
	break;
}

$smarty->assign(array(
    'id' => $id,
    'row' => htmlchar($row),
    'data_ary' => $data_ary,
    'page' => $page,
    'self' => $self,
    'skey' => $skey,
    'skey2' => $skey2,
    'skey3' => $skey3,
    'stype' => $stype,
    'stype2' => $stype2,
    'datas1' => $datas1,
    'group' => $group,
    'date' => $date,
    'result' => $result,
    'sum' => $sum,
    'plus_score'=>$plus_score,
    'minus_score'=>$minus_score,
    'type' => add_array_item(array('' => '全部'), $cf_info_var_common['user_score_log'])
));


$smarty->mydisplay();
?>